#include<bits/stdc++.h>
//#define int long long
using namespace std;
namespace AC{
void solve(){
    int n,m,L,V,ans1=0,ans2=0;
    cin>>n>>m>>L>>V;
    vector<array<int,3>>cars(n);
    for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>cars[i][j];
    vector<int>p(m);
    for(int i=0;i<m;i++)cin>>p[i];
    if(m<=20){
        int ans=0;
        vector<int>v;
        for(int i=0;i<n;i++)for(int j=0;j<m;j++){
            if((cars[i][1]*cars[i][1]+2*cars[i][2]*(p[j]-cars[i][0]))>V*V&&p[j]>=cars[i][0]){
                v.push_back(i);
                break;
            }
        }
        for(int i=0;i<(1<<m);i++){
            vector<int>vv(n+1);
            int cnt=0;
            for(int j=0;j<m;j++)if(i&(1<<j))for(int k=0;k<v.size();k++)if(!vv[v[k]])if(cars[v[k]][1]*cars[v[k]][1]+2*cars[v[k]][2]*(p[j]-cars[v[k]][0])>V*V){
                vv[v[k]]=1;
            }
            bool bl=0;
            for(int j=0;j<v.size();j++)if(!vv[v[j]]){
                bl=1;
                break;
            }
            if(bl)continue;
            for(int j=0;j<m;j++)if((i&(1<<j))==0)cnt++;
            ans=max(ans,cnt);
        }
        cout<<v.size()<<' '<<ans<<endl;
    }
    else{
        if(cars[0][2]>=0){
            int ans=0;
            for(int i=0;i<n;i++)if(cars[i][0]<=p[m-1]&&cars[i][1]*cars[i][1]+2*cars[i][2]*(p[m-1]-cars[i][0])>V*V)ans++;
            cout<<ans<<' '<<m-1<<endl;
        }
    }
}
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t=1;
    cin>>t;
    while(t--)AC::solve();
}
